<?php include('includes/before_html.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

    <head>

        <meta http-equiv="content-type" content="text/html; charset=utf-8" />

        <meta name="description" content="" />

        <meta name="keywords" content="" />

        <meta name="author" content="" />

        <?php include('includes/head.php'); ?>

        <title><?php echo $heading ?></title>
        <meta http-equiv="refresh" content="0; URL=messages.php"/>

    </head>

    <body>

        <div id="wrapper">

            <?php include('includes/header.php'); ?>

            <?php include('includes/nav.php'); ?>

            <div id="content">
                <?php
                if (isset($_GET['replyto']))
                    $replyto = $_GET['replyto'];
                else
                    $replyto = 'NULL';
                $db = mysql_connect(db_server, $db_user, $db_password);
                mysql_select_db($db_dbname);
                $sql1 = "INSERT INTO Messages (Body,ToID,FromID,Subject,Date,ReplyTo,Owner) VALUES ('" . addslashes($_POST['body']) . "'," . $_POST['to'] . "," . $myRuid . ",'" . addslashes($_POST['subject']) . "',NOW(),$replyto,$myRuid)";
                $result1 = mysql_query($sql1);
                $sql2 = "INSERT INTO Messages (Body,ToID,FromID,Subject,Date,ReplyTo,Owner) VALUES ('" . addslashes($_POST['body']) . "'," . $_POST['to'] . "," . $myRuid . ",'" . addslashes($_POST['subject']) . "',NOW(),$replyto,{$_POST['to']})";
                $result2 = mysql_query($sql2);
                echo "SQL Query:&nbsp;".$sql1."<br></br>";
                echo "SQL Query:&nbsp;".$sql2."<br></br>";
                if ($result1 && $result2)
                    echo "Message has been sent.";
                else {
                    echo "Error:&nbsp;".mysql_error();
                }
                ?>

            </div> <!-- end #content -->

            <?php include('includes/sidebar.php'); ?>

            <?php include('includes/footer.php'); ?>

        </div> <!-- End #wrapper -->

    </body>

</html>